import gradio as gr

def add_book(a,books):
    books.append(a)
    return books

with gr.Blocks() as demo:
    books = gr.State([]) # 定义一个状态变量
    inp = gr.Text()
    out = gr.Text()

    btn = gr.Button("添加")
    btn.click(add_book, inputs=[inp,books], outputs=out)

if __name__ == "__main__":
    demo.launch()